package com.study.signin_demo2.class03;

/**
 * @author whx
 * @date 2022/2/21
 */
public class C07_Lambda01 {

    public static void main(String[] args) {
        C01_NoReturnNoParam noReturnNoParam = new NoReturnNoParam();
        noReturnNoParam.hello();
        C01_NoReturnNoParam noReturnNoParam1 = () -> System.out.println("hello2");
        noReturnNoParam1.hello();

        C02_NoReturnOneParam noReturnOneParam = a -> System.out.println(a);
        // 当只有一个参数时，lambda表示式可以使用更加简洁的写法
        C02_NoReturnOneParam noReturnOneParam2 = System.out::println;
        noReturnOneParam.hello("hello3");
        noReturnOneParam2.hello("hello3");

        C03_NoReturnMultiParam noReturnMultiParam = (a,b) -> System.out.println(a+":"+b);
        noReturnMultiParam.hello("hello","world");

        System.out.println("---------");

        C04_ReturnNoParam returnNoParam = () -> "hello";
        String hello = returnNoParam.hello();
        System.out.println(hello);

        // 作业1：将带一个参数，多个参数并且有返回值的方法的lambda表达式书写出来


    }

    public static class NoReturnNoParam implements C01_NoReturnNoParam{
        @Override
        public void hello() {
            System.out.println("hello");
        }
    }
}
